<template>
	<view class="page">
		<view class="content-bg">
			<!-- <image class="image" src="https://pw.qyang.cc/static/login-bg2.png" mode="aspectFit"></image> -->
			<image id="image" class="image" :src="rq.imgUrl(bg)" mode="widthFix"></image>
		</view>
		<image class="logo" :src="rq.imgUrl(logo)" mode="widthFix"></image>
		<!-- <view style="width: 100%; height: 300rpx; position: relative;"></view> -->
		<view class="content" style="margin-top: 290px;">
			<view class="title">
				绑定手机号
			</view>
		</view>
		<view class="con1">
			<view class="input">
				<input class="input1" placeholder="请输入手机号" v-model="model.mobile" />
			</view>
			<view class="input">
				<input class="input1" placeholder="请输入验证码" v-model="model.captcha" />
				<view class="input3" @click="huoqu">
					{{codeText}}
				</view>
			</view>
			<view class="btn">
				<view class="btn1" @click="handBind">
					确认
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		isMobile
	} from '@/utils/util.js'
	export default {
		data() {
			return {
				codeText: '获取验证码',
				model: {
					mobile: '',
					captcha: ''
				},
				bg: '',
				logo: ''
			};
		},
		onLoad() {		
			this.rq.getData('common/logo').then(res => {
				this.bg = res.data.bg
				this.logo = res.data.logo
			})
		},
		methods: {
			handBind() {
				if (!isMobile(this.model.mobile)) {
					return
				}
				if (!this.model.captcha) {
					uni.showToast({
						title: '请输入验证码',
						icon: 'none'
					})
					return
				}
				console.log(this.model)
				this.rq.getData('user/mobile', this.model).then(res => {
					let userInfo = JSON.parse(uni.getStorageSync('userInfo'))
					if(userInfo.suibian===0){
						uni.reLaunch({
							url: '/subpages/settled/settled'
						})
					}else{
						uni.switchTab({
							url: '/pages/index/index'
						})									
					}
				}).catch(err=>{
					console.log(err)
				})
			},
			huoqu() {
				if (!isMobile(this.model.mobile)) {
					return
				}
				if (this.codeText !== '获取验证码') {
					return
				}
				this.rq.getData('Sms/send', {
					mobile: this.model.mobile,
					event: 'changemobile'
				}).then(res => {
					this.codeText = '60s'
					let time = 60
					const timer = setInterval(() => {
						time--
						this.codeText = time + 's'
						if (time == 0) {
							clearInterval(timer)
							this.codeText = '获取验证码'
						}
					}, 1000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		display: flex;
		flex-direction: column;
		// justify-content: flex-end;
		min-height: 100vh;
		background: #fff;
	}

	.logo {
		position: absolute;
		left: 50%;
		top: 200rpx;
		transform: translateX(-50%);
		width: 450rpx;
		z-index: 1;
	}

	.content-bg {
		background-color: #ffffff;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		z-index: 0;

		.image {
			width: 100vw;
			height: 100vh;
			// height: 667px;
			// margin-top: -350rpx;
		}
	}

	.con1 {
		position: relative;
		z-index: 2;
		padding: 40rpx;
		width: 100%;
		background: #FFF;
		background: linear-gradient(to bottom, #FFF, #FEF1F4);
		display: flex;
		flex-direction: column;
		bottom: 0;
		padding-bottom: 0rpx;
		box-sizing: border-box;
		flex: 1;

		.input {
			width: 100%;
			height: 48px;
			border-radius: 10px;
			opacity: 1;

			background: #FFFFFF;

			box-sizing: border-box;
			border: 1px solid #333333;
			display: flex;
			align-items: center;
			padding: 0 20rpx;
			margin-bottom: 20rpx;

			.input1 {
				width: 90%;
			}

			.input2 {
				width: 10%;
				padding: 0 10rpx;
				display: flex;
				justify-content: center;
			}

			.input3 {
				width: 30%;
				padding: 0 10rpx;
				display: flex;
				justify-content: center;
				font-family: 阿里巴巴普惠体 2.0;
				font-size: 14px;
				font-weight: 500;
				line-height: 20px;
				text-align: right;
				letter-spacing: 0px;
				color: #333333;
			}
		}

		.check {
			width: 100%;
			font-family: 阿里巴巴普惠体 2.0;
			font-size: 12px;
			font-weight: normal;
			line-height: 20px;
			letter-spacing: 0px;
			color: #999999;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.check1 {
				display: flex;
				align-items: center;
			}

			.text {
				color: #333333
			}

			.text1 {
				font-family: 阿里巴巴普惠体 2.0;
				font-size: 12px;
				font-weight: normal;
				line-height: 13px;
				text-align: center;
				letter-spacing: 0px;
				color: #FF7681;
			}
		}

		.btn {
			display: flex;
			flex-direction: column;

			.btn1 {
				width: 100%;
				height: 48px;
				border-radius: 10px;
				opacity: 1;
				background: #FF5866;
				box-sizing: border-box;
				border: 1px solid #FF5866;
				font-family: 阿里巴巴普惠体 2.0;
				font-size: 22px;
				font-weight: 500;
				line-height: 20px;
				letter-spacing: 0px;
				color: #FFFFFF;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 40rpx;
				letter-spacing: 10rpx;
			}

			.btn2 {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: 阿里巴巴普惠体 2.0;
				font-size: 12px;
				font-weight: normal;
				line-height: 20px;
				letter-spacing: 0px;
				color: #999999;
				margin-top: 40rpx;

				.register-btn {
					color: #FF7681;
				}
			}
		}


		.bottom {
			width: 100%;
			padding: 40rpx 0;

			.bottom-btn {
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 37px;
					height: 37px;
				}

			}
		}
	}



	.content {
		// margin-top: -300rpx;
		position: relative;
		z-index: 1;
		padding-left: 40rpx;
		background-color: #FFF;
		// background: url('https://pw.qyang.cc/static/bg-1.png') no-repeat center center/cover;
		// padding-top: 80rpx;
		// padding-top: 40rpx;

		.title {
			font-family: 阿里巴巴普惠体 2.0;
			font-size: 52rpx;
			font-weight: 500;
			line-height: 60rpx;
			letter-spacing: 0rpx;
			color: #333333;
		}

		.con {
			margin-top: 30rpx;
			margin-left: -20rpx;
		}


	}
</style>